import { http } from '@/utils/http';
import type { Class } from './index.d';

export { Class };

/** 教师加入班级 */
export const joinClass = (school_id: number, class_id: number) => {
	return http({
		url: `/api/teacher/teacher_join_class`,
		method: 'POST',
		data: { school_id, class_id },
	});
};

/** 教师创建班级 */
export const createClass = (school_id: number, class_name: string) => {
	return http({
		url: `/api/teacher/create_teacher_class`,
		method: 'POST',
		data: { school_id, class_name },
	});
};

/** 首页-班级图书完成度 */
export const getClassBookRateApi = (class_id: number, num: number) => {
	return http({
		url: `/api/plan/teacher/class_book_rate/${class_id}`,
		method: 'GET',
		data: { num },
	});
};

/** 首页-学生积分排行榜 */
export const getStudentRateApi = (class_id: number, num: number) => {
	return http({
		url: `/api/plan/teacher/student_top/${class_id}`,
		method: 'GET',
		data: { num },
	});
};

/** 首页-班级信息 */
export const getClassInfoApi = (class_id: number) => {
	return http({
		url: `/api/plan/teacher/class/${class_id}`,
		method: 'GET',
	});
};

/** 首页-班级动态信息 */
export const getClassMessageApi = (page: number, id: number) => {
	return http({
		url: `/api/plan/class_message`,
		method: 'GET',
		data: { page, id },
	});
};

/** 首页-编辑班级名称 */
export const editClassApi = (class_id: number, class_name: string) => {
	return http({
		url: `/api/teacher/edit_class_name`,
		method: 'POST',
		data: { class_id, class_name },
	});
};

/**  获取班级成员列表*/
export const getClassMembersApi = (class_id: number) => {
	return http({
		url: `/api/teacher/get_class_member`,
		method: 'POST',
		data: { class_id },
	});
};

/**获取班级成员列表-删除学生*/
export const delMemberApi = (class_id: number, student_id: number) => {
	return http({
		url: `/api/teacher/del_student`,
		method: 'POST',
		data: { class_id, student_id },
	});
};

/**教师退出班级*/
export const exitClassApi = (class_id: number) => {
	return http({
		url: `/api/teacher/teacher_quit_class`,
		method: 'POST',
		data: { class_id },
	});
};
